package com.ruoyi.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * AoiSpace短信常量
 */
public class ApiSpaceSmsConstants {

    @AllArgsConstructor
    @Getter
    public enum TemplateEnum {
        /**
         * 充值成功
         * 通知
         */
        MEMBER_RECHARGE("recharge", "【{sign}】您的充值已成功，充值金额为{$var}元，当前余额为{$var}元，请加油使用，感谢惠顾。"),
        /**
         * 一键加油微信支付通知
         * 通知
         */
        PETROL_WX("petrolWx", "【{sign}】您于{$var}在{$var}使用微信支付加油成功，加油金额为{$var}元，感谢惠顾。"),
        /**
         * 一键加油余额支付通知
         */
        PETROL_BALANCE("petrolBalance", "【{sign}】您于{$var}在{$var}使用余额支付加油成功，加油金额为{$var}元，当前余额为{$var}元，感谢惠顾。"),
        /**
         * 赠送优惠券
         * 通知
         */
        MEMBER_COUPON("couponReceive", "【{sign}】为了感谢您对本加油站的支持，赠送您一张{$var}优惠券，请打开{$var}小程序加油使用，谢谢。"),
        /**
         * 赠送通用
         * 通知
         */
        MEMBER_GIFT("giftReceive", "【{sign}】您有一份{$var}已到，请打开{$var}微信小程序加油查看，谢谢。地址：{$var}"),
        NULL("",""),
        ;
        private String code;
        private String templateText;

        public static TemplateEnum match(String code) {
            for (TemplateEnum one : TemplateEnum.values()) {
                if (one.getCode().equalsIgnoreCase(code)) {
                    return one;
                }
            }
            return TemplateEnum.NULL;
        }

        public static String getMatchContent(String code,Long shopId) {
            for (TemplateEnum one : TemplateEnum.values()) {
                if (one.getCode().equalsIgnoreCase(code)) {
                    return one.getTemplateText().replace("{sign}",SignEnum.match(shopId));
                }
            }
            return "";
        }

    }

    @AllArgsConstructor
    @Getter
    public enum SignEnum {
        DEFAULT(0,"阜鑫渔港加油站"),
        ;
        private int shopId;
        private String sign;

        public static String match(Long shopId) {
            for (SignEnum one : SignEnum.values()) {
                if (one.getShopId() == shopId) {
                    return one.getSign();
                }
            }
            return SignEnum.DEFAULT.getSign();
        }

    }
}
